package cate.game.play.skill.passive.hero;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.effect.SkillEffect;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 效果：使得【光明制裁】技能能够额外对2个随机目标造成60%伤害
 * 强化效果：增加的随机目标数提升至3个，并降低额外目标10%暴抗
 */
public class 秩序光辉PH extends PassiveHandler {

	private String 技能标签;

	private int 人数;

	private double 血量调整;

	private int buff;

	//技能标签=光明制裁&人数=2&血量调整=-4000&buff=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		技能标签 = args.get("技能标签");
		人数 = args.getInt("人数", 0);
		血量调整 = args.getWDouble("血量调整", 0d);
		buff = args.getInt("buff", 0);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		人数 += args.getInt("人数", 0);
		血量调整 += args.getWDouble("血量调整", 0d);
		buff = args.getInt("buff", buff);
	}


	@Override
	public void beforeOwnerMove(MoveCtx move, TimeActionCtx action) {
		if(!move.getSkill().cfg.containTag(技能标签)){
			return;
		}
		move.getSkill().param.addTargetNum(人数);
	}

	@Override
	public void afterSelectTargets(SkillActionCtx action, SkillEffect effect) {
		if (!action.getSkill().cfg.containTag(技能标签)) {
			return;
		}
		for (Fighter target : action.getExTargets()) {
			effect.getTargetCtx(target.getPid()).addHpChangeRate(血量调整);
		}
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (!action.getSkill().cfg.containTag(技能标签)) {
			return;
		}
		if (buff <= 0) {
			return;
		}
		for (Fighter target : action.getExTargets()) {
			target.buff.tryAddByTid(action, skill.owner, buff);
		}
	}
}
